ALMaSS  1.0
The Animal, Landscape and Man Simulation System
GeneticMaterial256_16 Class Reference

#include <GeneticMaterial.h>

Public Member Functions

 GeneticMaterial256_16 ()
 
void SetAllele (unsigned int locus, uint32 value, unsigned int Chromo)
 
uint32 GetAllele (unsigned int locus, unsigned int Chromo)
 
void Mutation_3 ()
 
void SetGeneticFlag ()
 
void SetDirectFlag ()
 
int HomozygosityCount ()
 
int HeterozygosityCount ()
 
void UnsetGeneticFlag ()
 
void UnsetDirectFlag ()
 
uint32 GetGeneticFlag ()
 
uint32 GetDirectFlag ()
 
void PrintGenes ()
 
void Recombine (GeneticMaterial256_16 *Gene1, GeneticMaterial256_16 *Gene2)
 
void Initiation (AlleleFreq256_16 *Al)
 

Protected Attributes

unsigned char Chromosome [32]
 

Constructor & Destructor Documentation

◆ GeneticMaterial256_16()

GeneticMaterial256_16::GeneticMaterial256_16 ( )
876  {
877  // ensure zeros in all loci
878  for ( int i = 0; i < 32; i++ ) Chromosome[ i ] = 0;
879 }
unsigned char Chromosome[32]
Definition: GeneticMaterial.h:195

References Chromosome.

Member Function Documentation

◆ GetAllele()

uint32 GeneticMaterial256_16::GetAllele ( unsigned int  locus,
unsigned int  Chromo 
)
889  {
890  if (Chromo==1) locus +=16;
891  return (uint32) Chromosome[ locus ];
892 }
unsigned int uint32
Definition: ALMaSS_Setup.h:34

References Chromosome.

Referenced by GetDirectFlag(), GetGeneticFlag(), Mutation_3(), and Recombine().

◆ GetDirectFlag()

uint32 GeneticMaterial256_16::GetDirectFlag ( )
939  {
940  return GetAllele(0,1);
941 }
uint32 GetAllele(unsigned int locus, unsigned int Chromo)
Definition: GeneticMaterial.cpp:889

References GetAllele().

◆ GetGeneticFlag()

uint32 GeneticMaterial256_16::GetGeneticFlag ( )
935  {
936  return GetAllele(0,0);
937 }

References GetAllele().

◆ HeterozygosityCount()

int GeneticMaterial256_16::HeterozygosityCount ( )
inline
204 { return 0; } // To add if needed

◆ HomozygosityCount()

int GeneticMaterial256_16::HomozygosityCount ( )
inline
203 { return 0; } // To add if needed

◆ Initiation()

void GeneticMaterial256_16::Initiation ( AlleleFreq256_16 Al)

The method called to intialise genes on initiation of the simulation.
Gene frequencies are based on an external text file input read in on construction.

965  {
966  uint32 value; //, c;
967  for ( int l = 0; l < 16; l++ ) {
968  int chance = random( 1000 );
969  uint32 index = 0;
970  while ( chance >= Al->SupplyAN( l, index ) ) {
971  index++;
972  }
973  value = index;
974  // set the value
975  SetAllele( l, value, 0 );
976  chance = random( 1000 );
977  index = 0;
978  while ( chance >= Al->SupplyAN( l, index ) ) {
979  index++;
980  }
981  value = index;
982  // set the value
983  SetAllele( l, value, 1 );
984  }
985 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
int SupplyAN(int loc, int al)
Definition: GeneticMaterial.h:189
void SetAllele(unsigned int locus, uint32 value, unsigned int Chromo)
Definition: GeneticMaterial.cpp:883

References random(), SetAllele(), and AlleleFreq256_16::SupplyAN().

◆ Mutation_3()

void GeneticMaterial256_16::Mutation_3 ( )

Move one allele one up or down

899 {
900  if (MutationChance != 0){
901  for ( int i = 0; i < 16; i++ ) {
902  if ( g_rand_uni() < MutationChance ) // one chance in Mutation Chance for the locus
903  {
904  unsigned strand = random( 2 ); // kromosom 0 or 1
905  int allele = GetAllele( i, strand );
906  if ( random( 2 ) == 1 ) allele++; else allele--;
907  //For mutations less than 0 and more than 256 the mutation should result in 1 or g_MaxAllele-1
908  if (allele > g_MaxAllele) allele-=2;
909  else if (allele < 0) allele = 1;
910  SetAllele( i, (uint32) allele, strand );
911  }
912  }
913  }
914 }
double MutationChance
Definition: GeneticMaterial.cpp:52
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
unsigned char g_MaxAllele
Definition: GeneticMaterial.cpp:53

References g_MaxAllele, g_rand_uni, GetAllele(), MutationChance, random(), and SetAllele().

◆ PrintGenes()

void GeneticMaterial256_16::PrintGenes ( )

◆ Recombine()

void GeneticMaterial256_16::Recombine ( GeneticMaterial256_16 Gene1,
GeneticMaterial256_16 Gene2 
)
944  {
945  // Is called with hers and his genes
946  for ( int i = 0; i < 16; i++ ) {
947  // For each locus
948  // Choose which chromosome for each parent
949  int g0 = random(2);
950  int g1 = random(2);
951  // get the two alleles
952  uint32 a0 = Gene1->GetAllele( i, g0 );
953  uint32 a1 = Gene2->GetAllele( i, g1 );
954  // put a0 into chromo0 & a1 to chromo1 & vice versa
955  SetAllele( i, a0, 0 );
956  SetAllele( i, a1, 1 );
957  }
958 }

References GetAllele(), random(), and SetAllele().

◆ SetAllele()

void GeneticMaterial256_16::SetAllele ( unsigned int  locus,
uint32  value,
unsigned int  Chromo 
)
883  {
884  if (Chromo==1) locus +=16;
885  Chromosome[ locus ] = (unsigned char) value;
886 }

References Chromosome.

Referenced by Initiation(), Mutation_3(), Recombine(), SetDirectFlag(), SetGeneticFlag(), UnsetDirectFlag(), and UnsetGeneticFlag().

◆ SetDirectFlag()

void GeneticMaterial256_16::SetDirectFlag ( )
921  {
922  SetAllele(0,1,1);
923 }

References SetAllele().

◆ SetGeneticFlag()

void GeneticMaterial256_16::SetGeneticFlag ( )
917  {
918  SetAllele(0,1,0);
919 }

References SetAllele().

◆ UnsetDirectFlag()

void GeneticMaterial256_16::UnsetDirectFlag ( )
930  {
931  SetAllele(0,0,1);
932 }

References SetAllele().

◆ UnsetGeneticFlag()

void GeneticMaterial256_16::UnsetGeneticFlag ( )
926  {
927  SetAllele(0,0,0);
928 }

References SetAllele().

Member Data Documentation

◆ Chromosome

unsigned char GeneticMaterial256_16::Chromosome[32]
protected

The documentation for this class was generated from the following files: